<template>
  <div>
    <el-button size="mini" type="primary" :icon="isView ? 'el-icon-more' : 'el-icon-edit'" @click="to" />
    <eForm ref="form" :sup-this="supThis" :is-add="false" :is-view="isView" />
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    },
    supThis: {
      type: Object,
      required: true
    },
    isAdd: {
      type: Boolean,
      required: true
    },
    isView: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    to() {
      const _this = this.$refs.form
      const checkBoxDatas = this.data.checkBoxDatas.map(item => item.id)
      _this.form = {
        id: this.data.id,
        typeId: this.data.typeId,
        typeName: this.data.typeName,
        objId: this.data.objId,
        objName: this.data.objName,
        templateName: this.data.templateName,
        templateDesc: this.data.templateDesc,
        checkBoxDatas
      }
      _this.defaultCheckBoxDatas = checkBoxDatas
      // _this.indexSelect(this.data.typeId)
      // _this.itemIds = []
      // this.data.checkBoxDatas.forEach(element => {
      //   _this.itemIds.push(element.id)
      // })
      // if (this.isView) {
      //   _this.dataitem = this.data.checkBoxDatas
      // } else {
      //   _this.queryItems({ pageNo: 0, size: 9999, objid: this.data.objId })
      // }
      _this.inited = false
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div{
    display: inline-block;
    margin-right: 3px;
  }
</style>
